﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;


namespace Launcher{
    public partial class Form1 : Form{
        public Form1(){
            InitializeComponent();
        }
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e){}
        private void openFileDialog1_FileOk(object sender, CancelEventArgs e){}
        private void label1_Click(object sender, EventArgs e){}
        private void label2_Click(object sender, EventArgs e){}

        private void Launch_Click(object sender, EventArgs e){
            //Save
            Launcher.Program.saveSettings();

            System.Diagnostics.Process.Start(openFileDialog1.InitialDirectory + openFileDialog1.FileName);
            Debug.WriteLine("Start:" + openFileDialog1.InitialDirectory + openFileDialog1.FileName);
        }
        private void Launch2_Click(object sender, EventArgs e){
            //Save
            Launcher.Program.saveSettings();

            System.Diagnostics.Process.Start(openFileDialog1.InitialDirectory + openFileDialog1.FileName);
            Debug.WriteLine("Start:" + openFileDialog1.InitialDirectory + openFileDialog1.FileName);
        }

        private void button1_Click(object sender, EventArgs e){
            openFileDialog1.FileName = "Game.exe";
            openFileDialog1.ShowDialog();
            Debug.WriteLine("Selected:" + openFileDialog1.InitialDirectory + openFileDialog1.FileName);
            this.button1.Text = openFileDialog1.FileName;
            this.Launch.Text = "Run " + openFileDialog1.FileName;
            this.Launch.Enabled = true;
            this.Launch2.Text = "Run " + openFileDialog1.FileName;
            this.Launch2.Enabled = true;
            //Save
            Launcher.Program.saveSettings();
        }

        private void bloom_CheckedChanged(object sender, EventArgs e){
            Launcher.Program.S.bloom = this.bloom.Checked;
            Debug.WriteLine("Bloom "+this.bloom.Checked);
            Debug.WriteLine("S Bloom " + Launcher.Program.S.bloom);
            //Save
            Launcher.Program.saveSettings();
        }

        private void Fullscreen_CheckedChanged(object sender, EventArgs e){
            Launcher.Program.S.fullscreen = this.Fullscreen.Checked;
            Debug.WriteLine("Full " + this.Fullscreen.Checked);
            Debug.WriteLine("S Full " + Launcher.Program.S.fullscreen);
            //Save
            Launcher.Program.saveSettings();
        }

        private void Form1_Load(object sender, EventArgs e){
            this.Fullscreen.Checked = Launcher.Program.S.fullscreen;
            this.bloom.Checked = Launcher.Program.S.bloom;
            string temp = "";
            temp = Launcher.Program.S.exeloc;
            if (temp != null)
            {
                if (temp != "")
                {
                    //at least "C:/A.exe" = 8
                    if (temp.Length >= 8)
                    {
                        openFileDialog1.FileName = temp;

                    }
                }
            }
        }

        
    }
}
